/* eslint-disable max-lines */
import * as BASE from '@/stores/definitions-base';
import { t } from '@lingui/macro';
import React, { } from 'react';
import { Tag } from '@alifd/next';

const {
  DATETIME_TEXT,
  DATE_TEXT,
  TIME_TEXT,
  EMPTY_TEXT,
  ENUMS: ENUMSBase,
  FieldsGrid: FieldGridBase,
  TitleGrid,
  column: columnBase,
  toSelectDataSource,
} = BASE;
export { DATETIME_TEXT, DATE_TEXT, EMPTY_TEXT, TIME_TEXT, TitleGrid, toSelectDataSource };

/**
 * @param {*} path        属性path
 * @param {*} props       column属性
 * @returns column定义
 */
export function column(...args) {
  return columnBase(partnerModal, ...args);
}

/**
 * 显示一组表单字段
 * ```js
 * {
 *   fields: string[],    // 字段名称，可以使用.来指定嵌套对象属性，例如order.busOrder.shift
 *   columns: number,     // 列数，默认为4,最大为12,最小为1
 *   model: object,       // 字段定义数据模型的根对象，默认不指定，仅在使用子对象作为根模型时设置
 *   overrideModel: object, // 重载字段定义数据模型
 *   mode: string,        // 表单模式，默认为edit，可选view
 *   itemLayout: object,  // FormItem布局配置，默认为{}
 * }
 * ```
 *
 * @param {object} param0
 * @returns
 */
export function FieldsGrid(props) {
  return <FieldGridBase model={partnerModal} {...props} />;
}

//----------------------------------------------------------------------
export const ENUMS = {
  ...ENUMSBase,
  status: {
    0: '禁用',
    1: '启用',
  },
};

export const partnerModal = {
  finished: {
    label: t`已结算佣金`,
    text: (v) => (
      <>
        <span>{'¥ '}</span>
        <span style={{ color: 'red' }}>{v}</span>
      </>
    ),
  },
  fullName: {
    label: t`姓名`,
  },
  fullname: {
    label: t`姓名`,
  },
  memberId: {
    label: t`标识`,
  },
  total: {
    label: t`总佣金`,
    text: (v) => (
      <>
        <span>{'¥ '}</span>
        <span style={{ color: 'green' }}>{v}</span>
      </>
    ),
  },
  genderText: {
    label: t`性别`,
  },
  mobile: {
    label: t`手机号`,
  },
  status: {
    label: t`状态`,
    text: (v) => (
      <Tag key={`p_n_${'blue'}`} type="normal" color={'blue'}>
        {ENUMS.status[v]}
      </Tag>
    ),
  },
};
